home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
appsrcs.zip
/
APPPRINT.ZIP
/
APPPRINT.OLD
< prev
next >
Wrap
Text File
|
1993-02-13
|
4KB
|
154 lines
/*-------------------------------------------------------------------------
AppPrint.c
A FilePrint tool for AppBar.
by
GMP van kempen
NEVERnever Software 1993
---------------------------------------------------------------------------*/
//compile with the strictest error checking
#define STRICT
#include <windows.h>
#include <windowsx.h>
#include <commdlg.h>
#include <cderr.h>
#include <string.h>
#include <stdio.h>
#include <shellapi.h>
#include <ctl3d.h>
#include "appprint.h"
HWND hWnd;
HINSTANCE hInst;
HICON hAppPrint;
char szAppName[] = "AppPrint";
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
static DLGPROC lpfnPrintDlgProc;
MSG msg;
WNDCLASS wndclass;
int Error;
if(!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = DLGWINDOWEXTRA;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, szAppName);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = COLOR_WINDOW + 1;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
}
Ctl3dRegister(hInstance);
Ctl3dAutoSubclass(hInstance);
hWnd = CreateWindow(szAppName, szAppName, WS_POPUP, 0, 0, 1, 1,
NULL, NULL, hInstance, NULL);
hInst = hInstance;
hAppPrint = LoadIcon(hInst, szAppName);
if(lstrlen(lpszCmdLine))
{
Error = ShellExecute(hWnd, "print", lpszCmdLine, NULL, NULL, NULL);
if(Error == 31)
OkMsgBox("AppPrint for AppBar","Could not print.\nNo association found\nfor dropped file.\n");
SendMessage(hWnd, WM_DESTROY, 0, 0);
}
else
{
lpfnPrintDlgProc = (DLGPROC) MakeProcInstance((FARPROC)PrintDlgProc, hInst);
DialogBox(hInst, "PrintDlg", hWnd, lpfnPrintDlgProc);
FreeProcInstance((FARPROC)lpfnPrintDlgProc);
SendMessage(hWnd, WM_DESTROY, 0, 0);
}
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Ctl3dUnregister(hInst);
return msg.wParam;
} /* end WinMain */
/*------------------------------------------------------------------------/
FUNCTION: WndProc()
/------------------------------------------------------------------------*/
long WINAPI WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, message, wParam, lParam);
}
/*------------------------------------------------------------------------/
FUNCTION: PrintDlgProc()
/------------------------------------------------------------------------*/
BOOL WINAPI PrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT ps;
RECT rc;
PRINTDLG pd;
char szPrinter[256];
char szCurrent[512];
switch(message)
{
case WM_INITDIALOG:
GetProfileString("windows", "device", "<none>", szPrinter, 200);
strcpy(szCurrent, "current printer: ");
strcat(szCurrent, szPrinter);
SetDlgItemText(hDlg, ID_TEXT, "current printer");
return TRUE;
case WM_PAINT:
hDC = BeginPaint(hDlg, &ps);
rc = ps.rcPaint;
if(IsIconic(hDlg))
DrawIcon(hDC, 0, 0, hAppPrint);
EndPaint(hDlg, &ps);
return 0;
case WM_COMMAND:
switch(wParam)
{
case ID_OK:
EndDialog(hDlg, 0);
SendMessage(hWnd, WM_DESTROY, 0, 0);
return TRUE;
case ID_HELP:
WinHelp(hDlg,"AppPrint.hlp", HELP_CONTENTS, 0L);
break;
case ID_PRINT:
/* Initialize PRINTDLG structure */
memset(&pd, 0, sizeof(PRINTDLG));
pd.lStructSize=sizeof(PRINTDLG);
pd.hwndOwner=hWnd;
pd.Flags=PD_RETURNIC | PD_PRINTSETUP;
/* display commondialog Print Dialog */
PrintDlg(&pd);
GetProfileString("windows", "device", "<none>", szPrinter, 255);
//vsprintf(szCurrent,"current printer: %s",szPrinter);
//SetDlgItemText(hDlg, ID_TEXT, szCurrent);
break;
}
break;
}
return FALSE;
} /* end PrintDlgProc */